<?php
use think\facade\Route;
use think\facade\Request;
use think\Response;
use mall\middleware\AllowOrigin;
use mall\middleware\VerifyToken;

Route::group(function() {
    Route::any("wechat.index/", "api/wechat.index/index");
    Route::any("wechat/notify", "api/wechat.index/notify");
});

Route::group(function(){
    Route::get('news/<id>', 'api/wap.news/view')->pattern(['id' => '[1-9]([\d]+)?']);//文章列表
    Route::post('public/login', 'api/wap.users/login');//登录
    Route::get('send_sms', 'api/wap.users/send_sms');//发送短信验证码
    Route::post('register', 'api/wap.users/register');//注册
    Route::post('forget', 'api/wap.users/forget');//忘记密码

    Route::post('ucenter/recharge_callback', 'api/wap.ucenter/rechargeCallback');//充值回调地址
    Route::get('ucenter/recharge_redirect', 'api/wap.ucenter/rechargeRedirect');//充值跳转
    Route::get('wallet/type', 'api/wap.WalletDetail/typeList'); //我的流水日志类型
    Route::get('auto', 'api/wap.auto/run'); //处理自动
    Route::get('test', 'api/wap.test/info');//测试
    Route::get('swoole', 'api/wap.swoole/test');//测试
    //Route::get('coin/trade_detail', 'api/wap.coinRule/detail'); //交易详情
    //Route::get('coin/trade_list', 'api/wap.coinRule/list');//交易对列表
    //Route::get('coin/rule_tips', 'api/wap.coinRule/getRuleTips');//交易日志
    //Route::get('coin/bill_log', 'api/wap.coinRule/billLog');//账单日志
    Route::get('banners', 'api/wap.banner/index'); //滚动图片
})->middleware(AllowOrigin::class);

Route::group(function(){
    Route::get('notices', 'api/wap.notice/index'); //首页公告
    Route::get('market', 'api/wap.coin/market');//市场行情
    Route::get('coin/list', 'api/wap.coin/list');//首页列表
    Route::get('coin/trade_list', 'api/wap.coinRule/list');//交易对列表
    Route::get('coin/trade_detail', 'api/wap.coinRule/detail'); //交易详情
    Route::post('coin/rule_bind', 'api/wap.coinRule/coinRuleBind');//交易规则设定
    Route::post('coin/rule_set', 'api/wap.coinRule/setRuleType');//交易类型设置
    Route::post('ucenter/login_out', 'api/wap.ucenter/loginOut');//退出登录
    Route::get('ucenter/key_list', 'api/wap.ucenter/keyList');//钥匙对列表
    Route::post('ucenter/key_bind', 'api/wap.ucenter/keyBind');//钥匙对绑定
    Route::post('ucenter/del_key', 'api/wap.ucenter/delKey');//钥匙对删除
    Route::post('ucenter/del_key', 'api/wap.ucenter/delKey');//钥匙对删除
    Route::post('ucenter/activate_vip', 'api/wap.ucenter/activate_vip');// 激活 vip
    Route::get('coin/rule_tips', 'api/wap.coinRule/getRuleTips');//交易日志
    Route::get('ucenter/info', 'api/wap.ucenter/info');//个人信息
    Route::get('coin/trade_log', 'api/wap.coinRule/getTradeLog');//交易日志
    Route::post('coin/deal_order', 'api/wap.coinRule/dealOrder');//订单操作
    Route::get('coin/bill_log', 'api/wap.coinRule/billLog');//账单日志
    Route::get('ucenter/account_log', 'api/wap.ucenter/account_log');//账户详情日志


    Route::post('ucenter/withdraw', 'api/wap.ucenter/withDraw');//提现
    Route::post('ucenter/recharge', 'api/wap.ucenter/recharge');//充值
    Route::get('ucenter/wallet', 'api/wap.ucenter/wallet');//我得钱包
    Route::post('job/issue', 'api/wap.job/issue');   // 发单
    Route::post('job/accept/<id>', 'api/wap.job/accept')->pattern(['id' => '[1-9]([\d]+)?']); //接单
    Route::get('my/accept', 'api/wap.jobAccept/myList'); //个人接单列表
    Route::get('my/accept/<id>', 'api/wap.jobAccept/myDetails'); //个人接单详情
    Route::post('my/accept_submit/<id>', 'api/wap.jobAccept/mySubmit'); //提交完成
    Route::get('my/issue', 'api/wap.job/myFetchList'); //我的发布
    Route::get('my/job_accept/<id>', 'api/wap.job/myAccepList')->pattern(['id' => '[1-9]([\d]+)?']); //我的发布中接单列表
    Route::post('my/accept_review_success/<id>', 'api/wap.jobAccept/statusSuccess')->pattern(['id' => '[1-9]([\d]+)?']); //接单审批通过
    Route::post('my/accept_review_fail/<id>', 'api/wap.jobAccept/statusFail')->pattern(['id' => '[1-9]([\d]+)?']); //接单审批失败
    Route::post('my/accept_appeal/<id>', 'api/wap.jobAccept/statusAppeal')->pattern(['id' => '[1-9]([\d]+)?']); //申请维权
    Route::post('my/level/issue_buy', 'api/wap.level/issueBuy'); //购买发布等级
    Route::post('my/level/accept_buy', 'api/wap.level/acceptBuy'); //购买接单等级
    Route::get('my/wallet_detail_log', 'api/wap.WalletDetail/myList'); //我的流水日志
    Route::post('job/edit/<id>', 'api/wap.job/edit')->pattern(['id' => '[1-9]([\d]+)?']); //更新任务
    Route::get('my/level', 'api/wap.level/fetch'); //我的等级列表


})->middleware(AllowOrigin::class)->middleware(VerifyToken::class);

Route::miss(function(){
    if(Request::isOptions()){
        return Response::create('ok')->code(200)->header([
            'Access-Control-Allow-Credentials' => 'true',
            'Access-Control-Allow-Origin'   => '*',
            'Access-Control-Allow-Headers'  => 'Auth-Token, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With',
            'Access-Control-Allow-Methods'  => 'GET,POST,PATCH,PUT,DELETE,OPTIONS',
            'Access-Control-Max-Age'        =>  '1728000'
        ]);
    }else{
        return Response::create()->code(404);
    }
});
